time=$(date +'%Y%m%d-%H%M%S')
ip=root@39.99.237.46
fileName=blueberry-package-$time.tag.gz
detailPath=/root/source/blueberry-nuxt
function title {
  echo
  echo "###############################################################################"
  echo "## $1"
  echo "###############################################################################"
  echo
}

# 删除 dist 目录中的所有文件
rm -rf dist/*

# docker打包
# docker exec -it nuxt_app tar -czvf $fileName .output .nuxt

# 压缩本地文件
tar -czvf dist/$fileName .nuxt .output

# # 下载到本地
# docker cp nuxt_app:/app/$fileName ./dist

# 上传服务器
title '上传文件'
scp ./dist/$fileName $ip:$detailPath

# # 进入目标目录
# # ssh $ip
# # cd $detailPath
# ssh root@39.99.237.46 "cd $detailPath"

# # 检查是否存在 .nuxt 或 .output 文件夹
# if [ -d .nuxt ] || [ -d .output ]; then
#     echo ".nuxt or .output folder exists. Do you want to delete them and unzip the file? (y/n):"
#     read delete_folders
#     if [ "$delete_folders" = "y" ]; then
#         if [ -d .nuxt ]; then
#             rm -rf .nuxt
#             echo ".nuxt folder deleted.";
#         fi
#         if [ -d .output ]; then
#             rm -rf .output
#             echo ".output folder deleted.";
#         fi
#         title '✨解压文件f'
#         tar -xzf $fileName
#     fi
# else
#     # 如果两个文件夹都不存在，直接解压文件
#     title '✨解压文件s'
#     tar -xzf $fileName
# fi
# 退出服务器
exit